package com.atguigu.gmall.item.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.SkuDetailsService;
import com.atguigu.gmall.product.vo.SkuDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tangsy
 * @Description TODO
 * @date 2022/12/4 11:29
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/inner/rpc/item")
public class SkuDetailsRpcController {

    @Autowired
    SkuDetailsService skuDetailsService;

    @GetMapping("/sku/detail/{skuId}")
    public Result<SkuDetailVo> getSkuDetails(@PathVariable("skuId")Long skuId) throws InterruptedException {
        SkuDetailVo skuDetailVo =  skuDetailsService.getSkuDetailData(skuId);
        skuDetailsService.incrHotScore(skuId);
        return Result.ok(skuDetailVo);
    }

}
